var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
   req.articals.find({}).toArray(function(err,items){
 	res.render('index',{articals:items});
// 	  console.log(items);
 	});
 });
router.delete('/:id',function(req,res,next){
	req.articals.removeById(req.params.id);
	res.send('200');
});
router.post('/articals/:id',function(req,res,next){
	console.log(req.body.id);
	res.articals.updateById(req.body.id,{title:req.body.title,content:req.body.content},function(){
		res.redirect('articles/post');
	})
	
});
module.exports = router;
